package com.tx.studentManager.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table(name = "student", catalog = "studentManager")
@DynamicInsert(true)
@DynamicUpdate(true)
public class Student extends BaseModel{
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(nullable = false)
	private Integer id;
	
	@Column(length = 18)
	private String name;
	
	@Column(length = 4,columnDefinition="char(4) default '男'")
	private String sex;
	
	@Column(length = 2,columnDefinition = "int(2) default 0")
	private Integer age;

	/**
	 * 此处注意，配置级联操作，否则插入时不对class表进行操作
	 * 一般对many-to-one,many-to-many不设置级联
	 */
	@ManyToOne
    @JoinColumn(name = "classId",insertable= true)
	private StudentClass studentClass;
	
	@Column(length = 50)
	private String address;
	
	private StudentInfo studentInfo;
	
	public Integer getId() {
		return id;
	}

	@Column(nullable = false)
	private Date createDate;
	
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public StudentClass getStudentClass() {
		return studentClass;
	}

	public void setStudentClass(StudentClass studentClass) {
		this.studentClass = studentClass;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public StudentInfo getStudentInfo() {
		return studentInfo;
	}

	public void setStudentInfo(StudentInfo studentInfo) {
		this.studentInfo = studentInfo;
	}

}
